package com.atguigu05._super;

import javax.sound.sampled.SourceDataLine;

/**
 * ClassName: PersonTest
 * Description:
 *
 * @Author liu
 * @Create 2024/10/27 21:39
 * @Version 1.0
 */
public class Student extends Person{
    String school;
    int id = 1002;

    public void setSchool(String school){
        this.school = school;
    }

    //方法
    public void study(){
        System.out.println("学生学习");
    }

    //方法重写
    public void eat(){
        System.out.println("学生多吃有营养的食物");
    }
    public void sleep(){
        System.out.println("学生要有10小时的睡眠");
    }

    //测试super调用方法与属性
    public void show(){
        eat();//student类，就近原则
        this.eat();//student类
        super.eat();//person类
    }
    public void show1(){
        //都为 person类，因为student类没有doSport方法，
        // 就向上调用person类
        doSport();
        this.doSport();
        super.doSport();
    }

    public void show2(){
        System.out.println(id);//1002
        System.out.println(this.id);//1002

        System.out.println(super.id);//1001
    }

    public void show3(){
        System.out.println(name);
        System.out.println(this.name);
        System.out.println(super.name);
    }

    //测试super调用父类的构造器
    public Student(){
        //super调用父类的结构器，会先调用父类的空构造器，再调用子类
        super();
        System.out.println("student() ~~~~");
    }

    public Student(String name,int age){
        super(name,age);
    }
}
